<?php

class Pengaduan_saran extends arfaController{
	
	public function __construct()
	{
		parent::__construct();
		$this->load->model("m_ps_pemohon");
		$this->load->model("m_list_pengaduan");
		$this->load->model("m_list_saran");
		$this->load->model("m_ijin_model");
		$this->load->model("m_proses_pengaduan_saran");
	}
	
	public function grid_dari_pemohon()
	{
		$data["data_ps_pemohon"] = $this->m_ps_pemohon->get_data();
		$data["menu"] 		= "admin";
		$data["content"] 	= $this->load->view("v_grid_ps_pemohon",$data,true);
		$this->load->view("main",$data);
	}
	
	public function grid_list_pengaduan()
	{
		$data["data_list_pengaduan"] = $this->m_list_pengaduan->get_data();
		$data["menu"] 		= "admin";
		$data["content"] 	= $this->load->view("v_grid_list_pengaduan",$data,true);
		$this->load->view("main",$data);
	}
	
	public function grid_list_saran()
	{
		$data["data_list_saran"] = $this->m_list_saran->get_data();
		$data["menu"] 		= "admin";
		$data["content"] 	= $this->load->view("v_grid_list_saran",$data,true);
		$this->load->view("main",$data);
	}
	
	public function form_input_ps($id = NULL , $id_saran = NULL)
	{
		$this->form_validation->set_rules("nama","Nama","required");
		$this->form_validation->set_rules("no_telp","Nomor Telepon","required");
		$this->form_validation->set_rules("email","Email","required");
		$this->form_validation->set_rules("isi","Isi","required");
	
		if($this->form_validation->run() == FALSE)
		{
			if(!isset($id))
			{
				$data["media"] = array(
				"" => "-- Pilih Media --",
				1 => "Langsung",
				2 => "Telepon",
				3 => "Email",
				4 => "Website"
				);
				$data["menu"] 			= "admin";
				$data["dropdown_ijin"] 	= $this->m_ijin_model->get();
				$data["post_action"]	= "pengaduan_saran/form_input_ps/";
				$data["content"] 		= $this->load->view("form_input_ps",$data,true);
				$this->load->view("main",$data);
			}
			else
			{
				if(!isset($id_saran)){
					$data["id"]	= $id;
					$data["media"] = array(
					"" => "-- Pilih Media --",
					1 => "Langsung",
					2 => "Telepon",
					3 => "Email",
					4 => "Website"
					);
					$data["menu"]					= "admin";
					$data["dropdown_ijin"] 			= $this->m_ijin_model->get();
					$data["list"]					= $this->m_list_pengaduan->get($id);
					$data["post_action"]			= "pengaduan_saran/form_input_ps/".$id;
					$data["content"]				= $this->load->view("form_input_ps",$data,true);
					$this->load->view("main",$data);
				}
				else
				{
					echo "saran";
					$data["id"]	= $id;
					$data["id_saran"] = $id_saran;
					$data["media"] = array(
					"" => "-- Pilih Media --",
					1 => "Langsung",
					2 => "Telepon",
					3 => "Email",
					4 => "Website"
					);
					$data["menu"]					= "admin";
					$data["dropdown_ijin"] 			= $this->m_ijin_model->get();
					$data["list"]					= $this->m_list_saran->get($id);
					$data["post_action"]			= "pengaduan_saran/form_input_ps/".$id;
					$data["content"]				= $this->load->view("form_input_ps",$data,true);
					$this->load->view("main",$data);
				}
			}
		}
		else
		{
			$get_nama 			= $this->input->post("nama");
			$get_notelp			= $this->input->post("no_telp");
			$get_email			= $this->input->post("email");
			$get_isi			= $this->input->post("isi");
			$get_media			= $this->input->post("media");
			$get_masukan		= $this->input->post("jenis_masukan");
			$get_ijin			= $this->input->post("ijin");
			$get_uptsa			= $this->input->post("no_uptsa");
			$get_tanggal		= $this->input->post("tanggal");
			$get_terkait_ijin	= $this->input->post("terkait_ijin");
			
			if($get_masukan == 1)
			{
				if($get_terkait_ijin == 1)
				{
					$data = array(
						"NAMA" 			=> $get_nama,
						"NO_TELEPON" 	=> $get_notelp,
						"EMAIL"			=> $get_email,
						"ISI"			=> $get_isi,
						"MEDIA"			=> $get_media,
						"KD_IJIN"		=> $get_ijin,
						"NO_UPTSA"		=> $get_uptsa,
						"TANGGAL"		=> date('Y-m-d', strtotime($get_tanggal)),
						"STATUS"		=> 2
					);
					
					if(!isset($id))
					{
						$this->m_list_pengaduan->save($data);
						echo"<script>location.reload();</script>";
					}
					else
					{
						$this->m_list_pengaduan->save($data,$id);
						redirect("pengaduan_saran/grid_list_pengaduan");
					}
				}
				elseif($get_terkait_ijin == 2)
				{
					$data = array(
						"NAMA" 			=> $get_nama,
						"NO_TELEPON" 	=> $get_notelp,
						"EMAIL"			=> $get_email,
						"ISI"			=> $get_isi,
						"MEDIA"			=> $get_media,
						"KD_IJIN"		=> NULL,
						"NO_UPTSA"		=> NULL,
						"TANGGAL"		=> date('Y-m-d', strtotime($get_tanggal)),
						"STATUS"		=> 2
					);
					
					if(!isset($id))
					{
						$this->m_list_pengaduan->save($data);
						echo "<script>location.reload();</script>";
					}
					else
					{
						$this->m_list_pengaduan->save($data,$id);
						redirect("pengaduan_saran/grid_list_pengaduan");
					}
				}
				
			}
			elseif($get_masukan == 2)
			{
				if($get_terkait_ijin == 1)
				{
					$data = array(
						"NAMA" 			=> $get_nama,
						"NO_TELEPON" 	=> $get_notelp,
						"EMAIL"			=> $get_email,
						"ISI"			=> $get_isi,
						"MEDIA"			=> $get_media,
						"KD_IJIN"		=> $get_ijin,
						"NO_UPTSA"		=> $get_uptsa,
						"TANGGAL"		=> date('Y-m-d', strtotime($get_tanggal)),
					);
					
					if(!isset($id))
					{
						$this->m_list_saran->save($data);
						echo "<script>location.reload();</script>";
					}
					else
					{
						$this->m_list_saran->save($data,$id);
						redirect("pengaduan_saran/grid_list_saran");
					}
				}
				elseif($get_terkait_ijin == 2)
				{
					$data = array(
						"NAMA" 			=> $get_nama,
						"NO_TELEPON" 	=> $get_notelp,
						"EMAIL"			=> $get_email,
						"ISI"			=> $get_isi,
						"MEDIA"			=> $get_media,
						"KD_IJIN"		=> NULL,
						"NO_UPTSA"		=> NULL,
						"TANGGAL"		=> date('Y-m-d', strtotime($get_tanggal)),
					);
					
					if(!isset($id))
					{
						$this->m_list_saran->save($data);
						echo "<script>location.reload();</script>";
					}
					else
					{
						$this->m_list_saran->save($data,$id);
						redirect("pengaduan_saran/grid_list_saran");
					}
				}
			}
		}
		
	}
	
	public function form_tindak_lanjut($id = NULL)
	{
		$this->form_validation->set_rules("form_input","Form Proses","required");
		
		if($this->form_validation->run() == FALSE)
		{
			$data["id"] = $id;
			$data["menu"]	= "admin";
			$data["get_id_status"] = $this->m_list_pengaduan->select_data($id);
			$data["get_data_proses"] = $this->m_proses_pengaduan_saran->get_all($id);
			$data["post_action"] = "pengaduan_saran/form_tindak_lanjut/".$id;
			$data["post_action2"] = "pengaduan_saran/cek_status";
			$data["content"] = $this->load->view("form_tindak_lanjut_pengaduan",$data,true);
			$this->load->view("main",$data);
		}
		else
		{
			$get_id_pengaduan = $id;
			$get_datetime = date("Y-m-d H:i:s");
			$get_keterangan = $this->input->post("form_input");
			
			$data = array(
				"KD_PENGADUAN_SARAN" => $get_id_pengaduan,
				"TANGGAL" => $get_datetime,
				"KETERANGAN" => $get_keterangan,
				"TESTIMONI" => 0
			);
			
			$this->m_proses_pengaduan_saran->save($data);
			echo "<script>location.reload();</script>";
		}
	}
	
	public function cek_status()
	{
		$this->form_validation->set_rules("testimoni","Proses","required");
	
		$get_id = $this->input->post("id_testimoni");
		$get_datetime = date("Y-m-d H:i:i");
		$get_testimoni = $this->input->post("testimoni");
		
		$data = array(
			"KD_PENGADUAN_SARAN" => $get_id,
			"TANGGAL" => $get_datetime,
			"KETERANGAN" => $get_testimoni,
			"TESTIMONI" => 1
		);
		$this->m_proses_pengaduan_saran->save($data);
		$data = array(
			"STATUS" => 1
		);
		$this->m_list_pengaduan->save($data,$get_id);
		redirect("pengaduan_saran/form_tindak_lanjut/".$get_id);
	}
	
	public function savetopengaduan($id)
	{
		$row = $this->m_ps_pemohon->get($id);
		$data = array(
			"NAMA"			=> $row['NAMA'],
			"NO_TELEPON"	=> $row['NO_TELPON'],
			"EMAIL"			=> $row['EMAIL'],
			"ISI"			=> $row['ISI'],
			"MEDIA"			=> $row['MEDIA'],
			"KD_IJIN"		=> $row['KD_IJIN'],
			"NO_UPTSA"		=> $row['NO_UPTSA'],
			"TANGGAL"		=> $row['TANGGAL'],
			"STATUS"		=> 2
		);
		$this->m_list_pengaduan->save($data);
		$this->m_ps_pemohon->delete($id);
		redirect("pengaduan_saran/grid_dari_pemohon");
	}
	
	public function savetosaran($id)
	{
		$row = $this->m_ps_pemohon->get($id);
		$data = array(
			"NAMA"			=> $row['NAMA'],
			"NO_TELEPON"	=> $row['NO_TELPON'],
			"EMAIL"			=> $row['EMAIL'],
			"ISI"			=> $row['ISI'],
			"MEDIA"			=> $row['MEDIA'],
			"KD_IJIN"		=> $row['KD_IJIN'],
			"NO_UPTSA"		=> $row['NO_UPTSA'],
			"TANGGAL"		=> $row['TANGGAL']
		);
		$this->m_list_saran->save($data);
		$this->m_ps_pemohon->delete($id);
		redirect("pengaduan_saran/grid_dari_pemohon");
	}
	
	public function data_report_saran()
	{
		$this->load->library('phpexcel');
		$this->load->library('PHPExcel/iofactory');
	
		$this->form_validation->set_rules("tanggal_awal","Tangga Awal","required");
		$this->form_validation->set_rules("tanggal_akhir","Tangga Akhir","required");
		
		if($this->form_validation->run() == FALSE)
		{
			$data["menu"]			= "admin";
			$data["post_action"]	= "pengaduan_saran/data_report_saran";
			$data["content"]		= $this->load->view("form_data_report_saran",$data,true);
			$this->load->view("main",$data);
		}
		else
		{
			$get_taw	= date('Y-m-d', strtotime($this->input->post("tanggal_awal")));
			$get_tak	= date('Y-m-d', strtotime($this->input->post("tanggal_akhir")));
			$get_data	= $this->m_list_saran->get_tanggal($get_taw,$get_tak);
			
			$date = date('m');
			if($date == 1){
				$get_date = "Januari";
			}elseif($date == 2){
				$get_date = "Februari";
			}elseif($date == 3){
				$get_date = "Maret";
			}elseif($date == 4){
				$get_date = "April";
			}elseif($date == 5){
				$get_date = "Mei";
			}elseif($date == 6){
				$get_date = "Juni";
			}elseif($date == 7){
				$get_date = "Juli";
			}elseif($date == 8){
				$get_date = "Agustus";
			}elseif($date == 9){
				$get_date = "September";
			}elseif($date == 10){
				$get_date = "Oktober";
			}elseif($date == 11){
				$get_date = "November";
			}elseif($date == 12){
				$get_date = "Desember";
			}
			
			//buat data sheet baru
			$objPHPExcel = new PHPExcel();
			$objPHPExcel->getProperties()->setTitle("title")->setDescription("description");
			
			$objPHPExcel->setActiveSheetIndex(0);
			
			//merge untuk judul
			$objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:I1');
			
			//mengatur lebar kolom jadi auto
			$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setAutoSize(true);
			$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setAutoSize(true);
			
			//mengatur teks align center
			$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			
			//mengatur border header tabel
			//$objPHPExcel->getActiveSheet()->getStyle('A4:E4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objPHPExcel->getActiveSheet()->getStyle('A4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('A4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('A4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('A4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('B4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('B4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('B4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('B4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('C4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('C4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('C4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('C4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('D4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('D4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('D4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('D4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('E4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('E4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('E4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('E4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('F4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('F4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('F4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('F4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('G4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('G4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('G4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('G4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('H4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('H4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('H4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('H4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('I4')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('I4')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('I4')->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			$objPHPExcel->getActiveSheet()->getStyle('I4')->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
			
			//setting teks
			$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(24);
			$objPHPExcel->getActiveSheet()->getStyle('A4:E4')->getFont()->setBold(true);
				
			//judul
			$objPHPExcel->getActiveSheet()->setCellValue('A1', "Laporan Kinerja Kepala Sub Unit Progra dan Informasi");
			
			//set bulan
			$objPHPExcel->getActiveSheet()->setCellValue('A3', "Tanggal Awal : ".$get_taw);
			$objPHPExcel->getActiveSheet()->setCellValue('B3', "Tanggal Akhir : ".$get_tak);
			
			//tabel header
			$objPHPExcel->getActiveSheet()->setCellValue('A4', "No");
			$objPHPExcel->getActiveSheet()->setCellValue('B4', "Nama");
			$objPHPExcel->getActiveSheet()->setCellValue('C4', "No Telepon");
			$objPHPExcel->getActiveSheet()->setCellValue('D4', "Email");
			$objPHPExcel->getActiveSheet()->setCellValue('E4', "Isi");
			$objPHPExcel->getActiveSheet()->setCellValue('F4', "Media");
			$objPHPExcel->getActiveSheet()->setCellValue('G4', "Jenis Ijin");
			$objPHPExcel->getActiveSheet()->setCellValue('H4', "No UPTSA");
			$objPHPExcel->getActiveSheet()->setCellValue('I4', "Tanggal");
			
			//isi kolom
			$no = 1;
			$numb = 5;
			foreach($get_data as $row){
				if($row["KD_IJIN"] == NULL){
					$nama_ijin = "-";
					$no_uptsa = "-";
				}else{
					$nama_ijin = $row["NAMA_IJIN"];
					$no_uptsa = $row["NO_UPTSA"];
				}
				if($row['MEDIA'] == 1){
					$media = "LANGSUNG";
				}elseif($row['MEDIA'] == 2){
					$media = "TELEPON";
				}elseif($row['MEDIA'] == 3){
					$media = "EMAIL";
				}elseif($row['MEDIA'] == 4){
					$media = "WEBSITE";
				}else{
					$media = "-";
				}
				$objPHPExcel->getActiveSheet()->getStyle('A'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('A'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('A'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('A'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('B'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('B'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('B'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('B'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('C'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('C'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('C'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('C'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('D'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('D'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('D'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('D'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('E'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('E'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('E'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('E'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('F'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('F'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('F'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('F'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('G'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('G'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('G'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('G'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('H'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('H'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('H'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('H'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('I'.$numb)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('I'.$numb)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('I'.$numb)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				$objPHPExcel->getActiveSheet()->getStyle('I'.$numb)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
				
				$objPHPExcel->getActiveSheet()->setCellValue('A'.$numb, $no);
				$objPHPExcel->getActiveSheet()->setCellValue('B'.$numb, $row["NAMA"]);
				$objPHPExcel->getActiveSheet()->setCellValue('C'.$numb, $row["NO_TELEPON"]);
				$objPHPExcel->getActiveSheet()->setCellValue('D'.$numb, $row["EMAIL"]);
				$objPHPExcel->getActiveSheet()->setCellValue('E'.$numb, $row["ISI"]);
				$objPHPExcel->getActiveSheet()->setCellValue('F'.$numb, $media);
				$objPHPExcel->getActiveSheet()->setCellValue('G'.$numb, $nama_ijin);
				$objPHPExcel->getActiveSheet()->setCellValue('H'.$numb, $no_uptsa);
				$objPHPExcel->getActiveSheet()->setCellValue('I'.$numb, date('d-m-Y',strtotime($row["TANGGAL"])));
				$numb++;
				$no++;
			}
			
			$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5');
			header('Content-Type: application/vnd.ms-excel');
			header('Content-Disposition: attachment;filename="Data Saran Report.xls"');
			header('Cache-Control: max-age=0');
			$objWriter->save('php://output');
			
		}
	}
}